<!--
 * @docName: entAccountManagementList.vue
 * @Author: mwl
 * @Date: 15:40
 * @LastEditors: mwl
 * @LastEditTime: 15:40
-->
<template>
  <a-card :bordered="false">
    <div class="table-page-search-wrapper" style="margin-top: 10px;">
      <a-form layout="inline">
        <a-row :gutter="24" style="margin-top: 10px">
          <a-col :md="6" :lg="6" :xl="7" :xxl="4">
            <a-form-item label="企业/法人名称">
              <a-input placeholder="请输入" v-model="queryParam.keyWord"></a-input>
            </a-form-item>
          </a-col>

          <a-col :md="8" :sm="10">
            <span  class="table-page-search-submitButtons">
             <a-button type="primary" @click="searchQuerys" icon="search">查询</a-button>
              <a-button @click="searchResets" icon="reload" style="margin-left: 10px">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <div>
      <a-table
        ref="table"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="tableData"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange"
        :scroll="{ x: 800}">

        <!-- 字符串超长截取省略号显示-->
        <span slot="esContent" slot-scope="text">
          <j-ellipsis :value="text" :length="10" />
        </span>
        <!--渠道类型-->
        <span slot="registerType" slot-scope="text, record">
            {{{1:'个体工商户',2:'个人独资企业',3:'有限公司',4:'合伙企业'}[text]}}
        </span>
        <span slot="action" slot-scope="text, record">
          <a href="javascript:;" @click="goTo(record)">查看充值账户</a>
        </span>
      </a-table>
    </div>
  </a-card>
</template>

<script>
import { cloneObject } from '@/utils/util'
import { getBusinessAccountEntList } from '@/api/account'
export default {
  name: 'entAccountManagementList',
  data() {
    return {
      loading: true,
      toggleSearchStatus: false,
      queryParam: {},
      tableData:[],
      columns: [
        {
          title: '企业名称',
          align: 'center',
          width: 80,
          dataIndex: 'entName',
        },
        {
          title: '社会统一代码',
          align: 'center',
          width: 120,
          dataIndex: 'lisenceCreditCode',
        },
        {
          title: '企业负责人',
          dataIndex: 'lisenceLegal',
          align: 'center',
          width: 240
        },
        {
          title: '负责人证件号',
          dataIndex: 'cardNumber',
          align: 'center',
          width: 130
        },
        {
          title: '企业类型',
          align: 'center',
          width: 180,
          dataIndex: 'registerType',
          scopedSlots: {customRender: 'registerType'},
        },
        {
          title: '操作',
          dataIndex: 'action',
          scopedSlots: {customRender: 'action'},
          align: 'center',
          width: 180,
          fixed: 'right'
        }
      ],
      /* 分页参数 */
      ipagination:{
        current: 1,
        pageSize: 10,
        total: 0,
        pageSizeOptions: ['10', '20', '30'],
        showTotal: (total, range) => {
          return " 共" + total + "条"
        },
        showSizeChanger: true,
      },
    }
  },
  created() {
    this.getTableData();
  },
  methods:{
    //首次获取表格数据
    getTableData(){
      this.loading = true;
      let params = {}; //查询条件
      let paramsNew = cloneObject(this.queryParam);
      params.data = paramsNew;
      params.pageNo = this.ipagination.current;
      params.pageSize = this.ipagination.pageSize;
      getBusinessAccountEntList(params).then(res => {
        if (res.success) {
          const data = res.result || {};
          // // 赋值表格数据
          this.tableData = data.records || [];
          // 赋值总条数
          this.ipagination.total = data.total || 0;
          this.loading = false;
        }else{
          this.$message.warning(res.message)
        }

      })
    },
    //查询
    searchQuerys() {
      this.getTableData();
    },
    //重置
    searchResets() {
      this.ipagination.current=1;
      this.queryParam = {};
      this.getTableData();
    },
    handleTableChange(pagination, filters, sorter) {
      //分页、排序、筛选变化时触发
      this.ipagination = pagination;
      this.getTableData();
    },
    //跳转详情
    goTo(record ,lock){
      this.$router.push({
        path: '/myAccount/entAccountManagementDetails',
        query:{
          bizId:record.id
        }
      });
    },
  }
}
</script>

<style scoped>

</style>
